﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ccit.Utils;
using System.Collections.Generic;

namespace Ccit.OA.NewsCenter
{
    public class LayoutBLL
    {
        /// <summary>
        /// 获取页面布局对象
        /// </summary>
        /// <param name="userId">用户ID(NEWS_B1_10))</param>
        /// <returns></returns>
        public MsLayout GetLayOutObj(string userId,string Type)
        {
            ILayout layout = GetBllObj();
            MsLayout layoutObj = layout.GetLayOutObj(userId,Type);
            layout = null;
            return layoutObj;
        }

        /// <summary>
        /// 布局设置
        /// </summary>
        /// <param name="layout">布局设置对象</param>
        /// <param name="selOnePlate">一列里板块</param>
        /// <param name="selTwoPlate">二列里板块</param>
        /// <param name="selThreePlate">三列里板块</param>
        /// <returns></returns>
        public List<string> SaveMsLayOut(MsLayout mslayout, string selOnePlate, string selTwoPlate, string selThreePlate, string selPlateId, string Type, string SysUserId)
        {
            ILayout layout = GetBllObj();
            List<string> strlist = layout.SaveMsLayOut(mslayout, selOnePlate, selTwoPlate, selThreePlate,selPlateId,Type,SysUserId);
            layout = null;
            return strlist;
        }

        /// <summary>
        /// 获取板块中图片板块的信息
        /// </summary>
        /// <returns></returns>
        public List<MsNews> GetPubNews(string Type)
        {
            ILayout layout = GetBllObj();
            List<MsNews> newsList = layout.GetPubNews(Type);
            layout = null;
            return newsList;
        }
        
        /// <summary>
        /// 判断当前用户是否有系统板块，没有添加
        /// </summary>
        /// <param name="Type"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool CheckSysPlate(string Type, string userId)
        {
            ILayout layout = GetBllObj();
            bool checkOper = layout.CheckSysPlate(Type, userId);
            return checkOper;
        }

        /// <summary>
        /// 取新用户的默认布局
        /// </summary>
        /// <param name="Type"></param>
        /// <returns></returns>
        public MsLayout GetLayOutDefault(string Type)
        {
            ILayout layout = GetBllObj();
            MsLayout layoutObj = layout.GetLayOutDefault(Type);
            layout = null;
            return layoutObj;
        }

        private ILayout GetBllObj()
        {
            ILayout layout = (ILayout)Factory.CreateObject("Ccit.OA.NewsCenter.dll", "Ccit.OA.NewsCenter.Layout",ImportComponentType.DotNetDll,null);
            return layout;
        }
    }
}
